<?php

class status_TagController extends Zend_Controller_Action
{
  function init() {
  	header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
	header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
    $this->getHelper('viewRenderer')->setNoRender();
  }

  //creation of a new status for the user
  function searchAction() {

    require_once('status/objects/tagsCounter.php'); 

    try{
      //as it is public timeline, wa can go directly in the status table to get them
	  $tagsList = Status_Object_TagsCounter::listing($this->_getParam('q'),$this->_getParam('where'),$this->_getParam('perPage'),$this->_getParam('page'));
    } catch(Status_Object_Exception $e) {
      $data['status'] = 	'KO';
      $data['error']['num'] = 	$e->getCode();
      $data['error']['message'] = 	$e->getMessage();
      echo Zend_Registry::get('dt_serializer')->serialize($data);	
      return;
    }
	$data['status'] = 	'OK';
	
	//we can t use status as it is alredy used to say evrything went fine
	$data['page'] = Status_Object_TagsCounter::formatPage($this->_getParam('page'));
	$data['perPage'] = Status_Object_TagsCounter::formatPerPage($this->_getParam('perPage'));	
	$data['tags'] =  $tagsList;	
	
	echo Zend_Registry::get('dt_serializer')->serialize($data);
    return;


  } //end searchAction
  
} //End class